package com.dianping.cat.configuration.web.url.transform;

import com.dianping.cat.configuration.web.url.entity.Code;
import com.dianping.cat.configuration.web.url.entity.PatternItem;
import com.dianping.cat.configuration.web.url.entity.UrlPattern;
import org.xml.sax.Attributes;








public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public Code buildCode(Attributes attributes) {
/* 20 */     String id = attributes.getValue("id");
/* 21 */     String name = attributes.getValue("name");
/* 22 */     String status = attributes.getValue("status");
/* 23 */     Code code = new Code((id == null) ? null : (Integer)convert(Integer.class, id, null));

/* 25 */     if (name != null) {
/* 26 */       code.setName(name);
    }

/* 29 */     if (status != null) {
/* 30 */       code.setStatus((Integer)convert(Integer.class, status, null));
    }

/* 33 */     return code;
  }


  public PatternItem buildPatternItem(Attributes attributes) {
/* 38 */     String group = attributes.getValue("group");
/* 39 */     String name = attributes.getValue("name");
/* 40 */     String pattern = attributes.getValue("pattern");
/* 41 */     String domain = attributes.getValue("domain");
/* 42 */     String id = attributes.getValue("id");
/* 43 */     PatternItem patternItem = new PatternItem(name);

/* 45 */     if (group != null) {
/* 46 */       patternItem.setGroup(group);
    }

/* 49 */     if (pattern != null) {
/* 50 */       patternItem.setPattern(pattern);
    }

/* 53 */     if (domain != null) {
/* 54 */       patternItem.setDomain(domain);
    }

/* 57 */     if (id != null) {
/* 58 */       patternItem.setId(((Integer)convert(Integer.class, id, Integer.valueOf(0))).intValue());
    }

/* 61 */     return patternItem;
  }



/* 66 */   public UrlPattern buildUrlPattern(Attributes attributes) { return new UrlPattern(); }





  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 73 */     if (value == null || value.length() == 0) {
/* 74 */       return defaultValue;
    }

/* 77 */     if (type == Boolean.class || type == boolean.class)
/* 78 */       return (T)Boolean.valueOf(value); 
/* 79 */     if (type == Integer.class || type == int.class)
/* 80 */       return (T)Integer.valueOf(value); 
/* 81 */     if (type == Long.class || type == long.class)
/* 82 */       return (T)Long.valueOf(value); 
/* 83 */     if (type == Short.class || type == short.class)
/* 84 */       return (T)Short.valueOf(value); 
/* 85 */     if (type == Float.class || type == float.class)
/* 86 */       return (T)Float.valueOf(value); 
/* 87 */     if (type == Double.class || type == double.class)
/* 88 */       return (T)Double.valueOf(value); 
/* 89 */     if (type == Byte.class || type == byte.class)
/* 90 */       return (T)Byte.valueOf(value); 
/* 91 */     if (type == Character.class || type == char.class) {
/* 92 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 94 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-core-3.0.0.jar!/com/dianping/cat/configuration/web/url/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */